package svgedit.gui.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import svgedit.gui.Frame;
import svgedit.gui.commands.Command;
import svgedit.gui.commands.DeleteCommand;
import svgedit.gui.commands.CommandStack;

/**
 * Deletes all selected elements.
 * 
 */
@SuppressWarnings("serial")
public class DeleteAction extends AbstractAction
{

	private Frame frame;

	/** Create this action for the given frame */
	public DeleteAction(Frame frame)
	{
		super("Delete");
		this.frame = frame;
	}

	@Override
	public void actionPerformed(ActionEvent ae)
	{

		Command delCommand = new DeleteCommand(frame.getView()
				.getSelectedElements());
		
		CommandStack.getInstance().addCommand(delCommand);		

		frame.getDocument().setModified(true);
		frame.getView().clearSelection();
		frame.repaint();
	}
}
